﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Botonet
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                Session.Abandon();
        }

        protected void idSubmit_Click1(object sender, EventArgs e)
        {
            cUser cUser = new cUser();

            if ((idPassword.Text != "") && (idUsuario.Text != ""))
            {

                if (cUser.login(idUsuario.Text, idPassword.Text))
                {   
                    if (Session["tipo"].ToString() == "admin")
                    {
                        Response.Redirect("admin.aspx", false);
                    }
                    else
                    {
                        Response.Redirect("Usuario.aspx", false);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "dialog", "<script type=\"text/javascript\">msg='<div id=\"txtMensaje\">" + cUser.error + "</div>';</script> ");
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "dialog", "<script type=\"text/javascript\">msg='<div id=\"txtMensaje\">Asegurese que los campos esten completos.</div>';</script> ");

            }
        }
    }
}